<%--
<!------------------------------------------------------------------------------
 - Copyright 2005 CORE Solutions Limited
 - All rights reserved.
 - PROPRIETARY AND CONFIDENTIAL INFORMATION.
 - Use is subject to license terms.
 -
 - FUNCTION ID      :   TASK
 - AUTHOR           :   Ric Yik 
 - DATE CREATE      :   2005/12/29
 - DESCRIPTION      :   a CHILD TAB JSP file for the function, TASK
 -                  :   
 -                  :   
 -                  :   
 -
 - MODIFICATION HISTORY:
 - DATE         AUTHOR          VERSION NO.         COMMENT
 - -----------  --------------  ------------------  -------------------
 - 2005/12/29   Ric Yik         1.0                 source is generated.
 -
 -
 -
------------------------------------------------------------------------------->

--%>
<%@ include file="/jsp/com/erp/app/common/jsp/directives_include.jsp"%>

<%@ page import="com.erp.app.setup.taskMaster.vo.TaskDtlVo"%>
<%@ page import="com.erp.app.setup.taskMaster.web.TaskMaintenanceAction"%>
<%@ page import="com.erp.app.setup.taskMaster.web.TaskMaintenanceForm"%>
<%@ page import="com.erp.app.setup.taskMaster.web.TaskDtlRow"%>

<%@ include file="/jsp/com/erp/app/common/jsp/html_include.jsp"%>

<jsp:useBean id="taskMaintenanceForm" scope="session" type="com.erp.app.setup.taskMaster.web.TaskMaintenanceForm" />
<script language="JavaScript">

function toGenericYN(yes) {
	return (yes) ? '<%=ProjectConstants.GENERIC_YES%>' : '<%=ProjectConstants.GENERIC_NO%>';
}

function doDtlIsDefault() {
	var dtlIsDefault = document.forms[0].dtlIsDefault;
	var dtlIsDefaultHidden = document.forms[0].dtlIsDefaultHidden;
	if (dtlIsDefault.length) {
		for (i = 0; i < dtlIsDefault.length; i++){
				document.forms[0].dtlIsDefault[i].value = toGenericYN(dtlIsDefaultHidden[i].checked);
		}
	} else {
		document.forms[0].dtlIsDefault.value = toGenericYN(dtlIsDefaultHidden.checked);
	}
}

</script>
<%
ArrayList taskDtlList = taskMaintenanceForm.getMultiRows(TaskMaintenanceAction.TAB_IDX_DTL);
pageContext.setAttribute("taskDtlList", taskDtlList);
%>

<chtml:button form="taskMaintenanceForm" pageEvent="<%=TaskMaintenanceAction.ACTION_ADD_DTL%>" styleClass="button1" />


<!-- MUST use the following to mark as mandatory field inputs-->
<!--<bean:message key="label.general.mandatory.field"/>-->

<%
rowReadOnly = false;
TableSchema[] childTsArray = taskMaintenanceForm.getChildTs();
TableSchema childTs = childTsArray[TaskMaintenanceAction.TAB_IDX_DTL];
%>

<table class="table_short_grid">
	<tr class="grid_header">
		<td class="grid_header" nowrap><html:text useExtensions="true" uiType="label" property="dtlSeq" childTsIndex="current"/></td>
		<td class="grid_header" nowrap><html:text useExtensions="true" uiType="label" property="dtlIsDefault" childTsIndex="current"/></td>
		<td class="grid_header" nowrap><html:text useExtensions="true" uiType="label" property="taskCode" childTsIndex="current"/></td>
		<td class="grid_header" nowrap><html:text useExtensions="true" uiType="label" property="dtlTaskDesc" childTsIndex="current"/></td>
		<td class="grid_header" nowrap><html:text useExtensions="true" uiType="label" property="dtlDateType" childTsIndex="current"/></td>
		<td class="grid_header" nowrap><html:text useExtensions="true" uiType="label" property="dtlDuration" childTsIndex="current"/></td>
		<td class="grid_header" width="1%"><html:text useExtensions="true" uiType="label" property="dtlNoDateFrom" childTsIndex="current"/></td>
		<td class="grid_header" nowrap><html:text useExtensions="true" uiType="label" property="dtlStatus" childTsIndex="current"/></td>
	</tr>
	<% int currentIndex = 0; %>
	<logic:iterate id="taskDtlRow" name="taskDtlList" indexId="idx"><%
		TaskDtlRow row = (TaskDtlRow) taskDtlRow;
		if ((row != null) && (CommonUtil.isEmpty(row.getIsDelete()))) {%>
		<tr <%=(idx.intValue() % 2 == 0) ? "class='grid_result1'" : "class='grid_result2'"%>>
			<td nowrap>
				<%
				colSize = String.valueOf(childTs.getColSizeByObjectId("LBL_DTL_SEQ"));
				displaySize = String.valueOf(childTs.getDisplaySizeByObjectId("LBL_DTL_SEQ"));
				%>
				<html:text property="dtlSeq" styleClass="textbox1" readonly="<%=rowReadOnly%>" maxlength="<%=colSize%>" size="<%=displaySize%>" value="<%=CommonUtil.nullToString(row.getDtlSeq())%>"/>
			</td>
			<td nowrap>
				<%
				colSize = String.valueOf(childTs.getColSizeByObjectId("LBL_DTL_IS_DEFAULT"));
				displaySize = String.valueOf(childTs.getDisplaySizeByObjectId("LBL_DTL_IS_DEFAULT"));
				%>
		    <input type="checkbox" name="dtlIsDefaultHidden" <%= (row.isDtlDefault()) ? "checked": "" %> onclick="javascript:doDtlIsDefault();"/>
				<html:hidden property="dtlIsDefault" value="<%= CommonUtil.nullToString(row.getDtlIsDefault()) %>" />
			</td>
			<td nowrap>
			<logic:equal name="taskDtlRow" property="rowModeCreate" value="true">
				<html:text property="taskCode" styleClass="textbox1" readonly="<%=rowReadOnly%>" maxlength="<%=colSize%>" size="<%=displaySize%>" value="<%=CommonUtil.nullToString(row.getTaskCode())%>"/>
			</logic:equal>
			<logic:notEqual name="taskDtlRow" property="rowModeCreate" value="true">
				<bean:write name="taskDtlRow" property="taskCode" filter="true"/>
				<html:hidden property="taskCode" value="<%=CommonUtil.nullToString(row.getTaskCode())%>" />
			</logic:notEqual>
			</td>
			<td nowrap>
			<%
				textAreaCols = String.valueOf(childTs.getTextAreaColSizeByObjectId("LBL_DTL_TASK_DESC"));
				textAreaRows = String.valueOf(childTs.getTextAreaRowSizeByObjectId("LBL_DTL_TASK_DESC"));
			%>
			<html:textarea property="dtlTaskDesc" styleClass="textarea1" readonly="<%=rowReadOnly%>" rows="<%=textAreaRows%>" cols="<%=textAreaCols%>" value="<%=CommonUtil.nullToString(row.getDtlTaskDesc())%>"/>
			<input type="button" name="..." value="..." class="button1" onclick="<%="doSubmit('pEditDtlTaskDesc', " + currentIndex++ + ")"%>"/>
			</td>
			<%--
			<td nowrap>
				<select name="dtlUserGroup" class="t2" onchange="doSubmit('doNothing');">
					<% where = "COMPANY_CODE = '" + WebUtil.getAppropriateCompanyCode(session, null) + "'"
										+ " and (status = '" + ProjectConstants.GENERIC_ACTIVE + "' or dept_code = '" + row.getDtlUserGroup() + "')";
					%>
					<option value="">
					<chtml:options table="T_dept_hdr"
								valuecolumn="dept_code"
								textcolumn=" dept_code || ' - ' || description "
								where= "<%=where%>"
								order="dept_code"
								selected="<%=row.getDtlUserGroup()%>" />
				</select>
			</td>
			--%>
			<%--
			<td nowrap>
				<select name="dtlUserCode" class="t2">
					<% where = "COMPANY_CODE = '" + WebUtil.getAppropriateCompanyCode(session, null) + "'"
										+ " and (ACTIVATION = '" + ProjectConstants.GENERIC_ACTIVE + "' or USER_CODE = '" + row.getDtlUserCode() + "')"
										+ " and dept = '" + CommonUtil.nullToString(row.getDtlUserGroup()) + "'";
					%>
					<option value="">
					<chtml:options table="T_USER"
								valuecolumn="USER_CODE"
								textcolumn=" USER_CODE || ' - ' || USER_NAME "
								where= "<%=where%>"
								order="USER_NAME"
								selected="<%=row.getDtlUserCode()%>" />
				</select>
			</td>
			--%>
			<td nowrap>
			<select name="dtlDateType" class="t2">
				<%
				where = "COMPANY_CODE ='" + WebUtil.getAppropriateCompanyCode(session, null) + "' AND DOC_TYPE = '" + taskMaintenanceForm.getDocType() + "'";
				%>
				<chtml:options table="T_TASK_DATE_TYPE"
							valuecolumn="DATE_TYPE"
							textcolumn="DATE_TYPE_DESC"
							where= "<%=where%>"
							order="DATE_TYPE_DESC"
							selected="<%=row.getDtlDateType()%>" />
			</select>
			</td>
			<td nowrap>
				<%
				colSize = String.valueOf(childTs.getColSizeByObjectId("LBL_DTL_DURATION"));
				displaySize = String.valueOf(childTs.getDisplaySizeByObjectId("LBL_DTL_DURATION"));
				%>
				<html:text property="dtlDuration" styleClass="textbox1" readonly="<%=rowReadOnly%>" maxlength="<%=colSize%>" size="<%=displaySize%>" value="<%=CommonUtil.nullToString(row.getDtlDuration())%>"/>
			</td>
			<td nowrap>
				<%
				colSize = String.valueOf(childTs.getColSizeByObjectId("LBL_DTL_NO_DATE_FROM"));
				displaySize = String.valueOf(childTs.getDisplaySizeByObjectId("LBL_DTL_NO_DATE_FROM"));
				%>
				<html:text property="dtlNoDateFrom" styleClass="textbox1" readonly="<%=rowReadOnly%>" maxlength="<%=colSize%>" size="<%=displaySize%>" value="<%=CommonUtil.nullToString(row.getDtlNoDateFrom())%>"/>
			</td>
			<td nowrap>
				<select name="dtlStatus" <%=formReadOnly ? "disabled=\"true\"" : ""%> class="selectBox1">
					<%where = "(TYPE = '" + ProjectConstants.CONSTANT_TYPE_ACT_INACT + "' OR CONSTANT_CODE = '" + row.getDtlStatus() + "')";%>
					<chtml:options table="T_SYS_CONSTANTS"
					valuecolumn="CONSTANT_CODE"
					textcolumn="CONSTANT_NAME"
					where= "<%=where%>"
					order="ORDER_SEQ"
					selected="<%=row.getDtlStatus()%>" />
				</select>
			</td>
		</tr>
		<%} else {%>
		<html:hidden property="isDelete" value="<%=row.getIdx()%>"/>
		<!--MUST INCLUDE hidden fields for all input objects such as textbox, textarea, check box, radio button, select box, etc.-->
		<html:hidden property="dtlTaskDesc" value="<%=CommonUtil.nullToString(row.getDtlTaskDesc())%>"/>
		<html:hidden property="dtlUserGroup" value="<%=CommonUtil.nullToString(row.getDtlUserGroup())%>"/>
		<html:hidden property="dtlUserCode" value="<%=CommonUtil.nullToString(row.getDtlUserCode())%>"/>
		<html:hidden property="dtlDateType" value="<%=CommonUtil.nullToString(row.getDtlDateType())%>"/>
		<html:hidden property="dtlNoDateFrom" value="<%=CommonUtil.nullToString(row.getDtlNoDateFrom())%>"/>
		<html:hidden property="dtlDuration" value="<%=CommonUtil.nullToString(row.getDtlDuration())%>"/>
		<html:hidden property="dtlStatus" value="<%=CommonUtil.nullToString(row.getDtlStatus())%>"/>
		<html:hidden property="dtlIsDefault" value="<%=CommonUtil.nullToString(row.getDtlIsDefault())%>"/>
		<%}%>
		<html:hidden property="idx" value="<%=row.getIdx()%>" />
		<html:hidden property="rowMode"  value="<%=row.getRowMode()%>"/>
	</logic:iterate>
</table>

